package com.fcscs.cservice.communication.printer;

import java.io.Serializable;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.fcscs.core.printing.ServerPrinter;
import com.fcscs.cservice.communication.CommIntfAdaptor;

@Service("printerAdaptor")
public class PrinterAdaptor implements CommIntfAdaptor {

	@Override
	public byte[] transport(byte[] data, Map<CommParam, Serializable> params) {
		try {
			String msg = (String)params.get(CommParam.TITLE) + "\n" + new String(data);
			ServerPrinter.printMessage((String)params.get(CommParam.TITLE), (String)params.get(CommParam.DEVICE),
					(Integer)params.get(CommParam.FONT_SIZE), msg);
			return data;
		} catch (Exception e) {
			return null;
		}
	}
}
